## example

TARGET   = hello.efi

CC       = clang
LD       = lld
UEFIDIR ?= ../

CFLAGS   = -target x86_64-pc-win32-coff -fno-builtin -ffreestanding -fno-stack-protector -fshort-wchar -mno-red-zone
CLDFLAGS = -flavor link -subsystem:efi_application -entry:efi_main

CSRCS    = $(wildcard ./*.c)

CFLAGS  += -I $(UEFIDIR)  -I .
CSRCS   += $(UEFIDIR)/uefi_helper.c

COBJS    = $(patsubst %.c, %.o, $(CSRCS))

all: $(TARGET)


%.efi: $(COBJS)
	$(LD) $(CLDFLAGS) $^ -out:$@

%.o: %.c
	$(CC) $< $(CFLAGS) -c -o $@

clean:
	rm -rf *.efi *.o NvVars

EFI_DIR = .
run: all
	qemu-system-x86_64 -net none -serial stdio -vga std -bios OVMF.fd -m 512 --no-shutdown --no-reboot -hda fat:rw:$(EFI_DIR)
